package com.myproject.mall.domain.dto;

import com.myproject.mall.domain.entity.*;
import lombok.Data;

import java.math.BigDecimal;

@Data
public class GoodsDTO {
    private Long goodsId;
    private String goodsTitle;
    private String goodsDescription;

    private String userId;
    private String userName;

    private Long shopId;
    private String shopTitle;

    private Long brandId;
    private String brandName;

    private Integer categoryId;
    private String categoryTitle;

    private Integer amount;
    private BigDecimal price;
    private String unit;
    private String size;
    private Integer salesVolume;
    private String pictures;

    public static GoodsDTO of(Goods goods, User user, Shop  shop, Brand  brand, Category category) {
        GoodsDTO goodsDTO = new GoodsDTO();
        goodsDTO.setGoodsId(goods.getId());
        goodsDTO.setGoodsTitle(goods.getTitle());
        goodsDTO.setGoodsDescription(goods.getDescription());
        goodsDTO.setUserId(user.getId());
        goodsDTO.setUserName(user.getUsername());
        goodsDTO.setShopId(shop.getId());
        goodsDTO.setShopTitle(shop.getTitle());
        goodsDTO.setBrandId(brand.getId());
        goodsDTO.setBrandName(brand.getBrandName());
        goodsDTO.setCategoryId(category.getId());
        goodsDTO.setCategoryTitle(category.getTitle());
        goodsDTO.setAmount(goods.getAmount());
        goodsDTO.setPrice(goods.getPrice());
        goodsDTO.setUnit(goods.getUnit());
        goodsDTO.setSize(goods.getSize());
        goodsDTO.setSalesVolume(goods.getSalesVolume());
        goodsDTO.setPictures(goods.getPictures());

        return goodsDTO;
    }
}
